package com.startup;

import java.io.IOException;
import java.sql.Connection;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.databasefunction.AllDBFunction;
import com.databasefunction.DatabaseConnection;
import com.databasefunction.DatabaseConstants;


/**
 * Servlet implementation class Loadconfig
 */

public class Loadconfig extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Loadconfig() {
       
    	super();
        // TODO Auto-generated constructor stub
    	Connection connection;
    	DatabaseConnection database_connection = new DatabaseConnection();
    	AllDBFunction allDBFunction = new AllDBFunction();
    	database_connection=new DatabaseConnection();
    	connection=database_connection.getConnection(null);
    	database_connection.createDatabase(connection);
    	
    	//Pundlik
    	connection=database_connection.getConnection(DatabaseConstants.dbName);
    	allDBFunction.createTableUsers(connection);
    	allDBFunction.createTableAddDealers(connection);
    	allDBFunction.createTableBarcodeFinal(connection);
    	allDBFunction.createTableAnalysis(connection);
    	
    	allDBFunction.addUser("superadmin", "superadmin", "superadmin");
    	System.out.println("Loaded");
    	 
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
